package pCloud.service;

import java.util.HashMap;

import pCloud.message.ClientResponse;

//This is used by different threads, maintaining responses to ClientRequest
//that has yet to be fulfilled, i.e. still waiting for reply from server.
public class IncompleteResponse {
	HashMap<Integer, ClientResponse> incompleteResponses;

	public IncompleteResponse(){
		incompleteResponses = new HashMap<Integer, ClientResponse>();
	}
	
	public synchronized void addResponse(ClientResponse response){
		this.incompleteResponses.put(response.getId(), response);
	}
	
	public synchronized ClientResponse getIncompleteResponse(int id){
		return this.incompleteResponses.get(id);
	}
	
	public synchronized void removeResponse(int id){
		this.incompleteResponses.remove(id);
	}
}
